package com.project.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.project.bean.ClientBean;
import org.apache.ibatis.annotations.*;

import java.time.LocalDate;
import java.util.List;

/**
 * 客户表mapper接口
 */
@Mapper
public interface IClientMapper extends BaseMapper<ClientBean> {

    /**
     * 模糊查询，
     * 根据客户名称，经营范围，
     * 查询出客户名称，负责人，经营范围
     * @clientName        客户名称
     * @return  分页对象    经营范围
     */
    public List<ClientBean> findByItem(@Param("clientName") String clientName, @Param("clientRange") String clientRange);

    /***
     * 添加客户信息
     * @param client    客户对象
     */
    @Insert("INSERT INTO sys_client(clientName,cLIEntManager,clientRange,clientPhone,cLIentAddress,clientEmail)VALUES(#{clientName},#{clientManager},#{clientRange},#{clientPhone},#{clientAddress},#{clientEmail})")
    public void addClient(ClientBean client);


    /***
     * 按照id查询
     * @param id    id
     */
    @Select("select * from sys_client where pk_clientId=#{id}")
    @ResultMap("clientMap")
    public ClientBean findById(int id);

    /**
     *按id修改客户信息，修改负责人，电话，经营范围
     * @param id                id
     * @param clientManager     负责人
     * @param clientPhone       负责人电话
     * @param clientRange       经营范围
     */
    @Update("update sys_client set clientManager=#{clientManager},clientPhone=#{clientPhone},clientRange=#{clientRange} where pk_clientId=#{id}")
    public void updateClient(@Param("id") int id, @Param("clientManager")String clientManager, @Param("clientPhone")String clientPhone, @Param("clientRange")String clientRange);


    /**
     * 查询所有客户
     * @return 集合
     */
    @Select("select * from sys_client")
    @ResultMap("clientMap")
    public List<ClientBean> findAll();


    public List<ClientBean> findMoneyByItem(String client, LocalDate startDate, LocalDate endDate);
}
